//
//  NYExamineViewStartTestViewController.m
//  NiuWaJiaoYu
//
//  Created by 袁航 on 2018/1/9.
//  Copyright © 2018年 niuwaketang. All rights reserved.
//

#import "NYExamineViewStartTestViewController.h"
#import "NYExamineStartTestRequest.h"
#import "NYExamineTestViewController.h"
@interface NYExamineViewStartTestViewController ()

@property (nonatomic, copy) NSString *examine_id;
@property (nonatomic, assign) NYExamineRequestStatus status;

@end

@implementation NYExamineViewStartTestViewController

- (instancetype)initWithExamineRequestStatus:(NYExamineRequestStatus)status withExamineID:(NSString *)examine_id {
        self = [super init];
        if (self) {
                self.status = status;
                self.examine_id = examine_id;
        }
        return self;
}
- (void)viewDidLoad
{
        [super viewDidLoad];
        [self loadData];
}
- (void)initSubviews
{
        [super initSubviews];
        @weakify(self);
        [self.controllerView.startTestBtn jk_addActionHandler:^(NSInteger tag) {
                @strongify(self);
                NYExamineTestViewController *vc = [[NYExamineTestViewController alloc] initWithExamineRequestStatus:self.status  withExamineID:self.examine_id];
                [self.navigationController pushViewController:vc animated:YES];
        }];
}
- (void)loadData
{
        [self setLoading:YES animation:YES];
        [self configNimbus];
        [[NYExamineStartTestRequest requestWithType:_status param:@{
                                                             kRequestKeyExamineID : NOT_NULL_STRING_DEFAULT_EMPTY(self.examine_id)
                                                             }] startWithSuccess:^(__kindof BaseRequest * _Nonnull request, __kindof NYExamineStartTestModel * _Nonnull data) {
                [self.tableViewModel addObject:data];
                [self.tableView reloadData];
                [self setSuccess];
        } failed:^(__kindof BaseRequest * _Nonnull request, NSError * _Nonnull error) {
                [self setError:error];
        }];
}
- (void)configNavigationBar:(BaseNavigationBar *)navigationBar
{
        [super configNavigationBar:navigationBar];
        NSString *title = @"考试";
        switch (self.status) {
                case NYExamineRequestStatusChoose:
                {
                        title = @"自测卷";
                }
                        break;
                case NYExamineRequestStatusCup:
                {
                        title = @"杯赛";
                }
                        break;
                case NYExamineRequestStatusTest:
                {
                        title = @"考试";
                }
                        break;
                        
                default:
                        break;
        }
        self.title = title;
}
+ (NYViewControllerNavigationBarType)navigationBarType
{
        return NYViewControllerNavigationBarTypeBlue;
}
@end
